﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using Fabrication.ValueProviders;

namespace Fabrication
{
    public static class EnumerableRuleExtensions
    {
        public static IBuilderOptions<T> Generate<T, TParam>(this PropertySelector<T, IList<TParam>> propertySelector, int numberOfItems)
        {
            var provider = new ListValueProvider<TParam>(numberOfItems);
            return propertySelector.Use(provider);
        }

        public static IBuilderOptions<T> Generate<T, TParam>(this PropertySelector<T, IList<TParam>> propertySelector, int minimumItems, int maximumItems)
        {
            var provider = new ListValueProvider<TParam>(minimumItems, maximumItems);
            return propertySelector.Use(provider);
        }

        public static IBuilderOptions<T> Generate<T, TParam>(this PropertySelector<T, List<TParam>> propertySelector, int numberOfItems)
        {
            var provider = new ListValueProvider<TParam>(numberOfItems);
            return propertySelector.Use(provider);
        }

        public static IBuilderOptions<T> Generate<T, TParam>(this PropertySelector<T, List<TParam>> propertySelector, int minimumItems, int maximumItems)
        {
            var provider = new ListValueProvider<TParam>(minimumItems, maximumItems);
            return propertySelector.Use(provider);
        }

        public static IBuilderOptions<T> Generate<T, TParam>(this PropertySelector<T, ICollection<TParam>> propertySelector, int numberOfItems)
        {
            var provider = new CollectionValueProvider<TParam>(numberOfItems);
            return propertySelector.Use(provider);
        }

        public static IBuilderOptions<T> Generate<T, TParam>(this PropertySelector<T, ICollection<TParam>> propertySelector, int minimumItems, int maximumItems)
        {
            var provider = new CollectionValueProvider<TParam>(minimumItems, maximumItems);
            return propertySelector.Use(provider);
        }

        public static IBuilderOptions<T> Generate<T, TParam>(this PropertySelector<T, Collection<TParam>> propertySelector, int numberOfItems)
        {
            var provider = new CollectionValueProvider<TParam>(numberOfItems);
            return propertySelector.Use(provider);
        }

        public static IBuilderOptions<T> Generate<T, TParam>(this PropertySelector<T, Collection<TParam>> propertySelector, int minimumItems, int maximumItems)
        {
            var provider = new CollectionValueProvider<TParam>(minimumItems, maximumItems);
            return propertySelector.Use(provider);
        }
    }
}